<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
    <link rel="stylesheet" href="../css/login.css">
    <link rel="stylesheet" href="../css/footer.css">
    <link rel="stylesheet" href="../css/header_login.css">
    <link rel="icon" href="../images/小图标.jpg"> 
    <script>
        function userLogin(){
            var name = document.querySelector('#nickName').value
            var pwd = document.querySelector('#pwd').value
            //1.通过AJAX访问服务器接口，进行注册
            $.ajax({
                url:'http://localhost:3000/api/login',
                type:'post',
                data:{userName:name,userPwd:pwd},
                success:function(result){
                    console.log(result)
                    if(result.message == 'ok'){
                        //2.跳转到登录页面
                        alert('登录成功！')
                        localStorage.setItem('currentUser',JSON.stringify(result.data))
                        location.href = 'personal.html'
                    }else{
                        alert('登录失败！')
                    }
                }
            })
        }
    </script>
</head>
<body>
    <header>
        <div>
            <a href="../html/index.html"><img src="../images/login.png" alt=""></a>
    </header>
    <div class="login-background">
        <div class="content-box">
            <div class="middle-box">
            <div class="form-login-box">
                
                    <div class="login-regi-title">
                    <h2 class="active">账号密码登录</h2>
                </div>
                <!-- 账号密码登录 -->
                <div class="form-content">
                    <form method="get">
                        <ul>
                            <li>
                                <input name="userName" name="userName" id="nickName" class="usertel" type="text" placeholder="请输入您的账号">
                            </li>
                            <li>
                                <input name="userPwd" name="userPwd" id="pwd" class="userpwd" type="password" placeholder="输入密码">
                            </li>
                            <li class="err-text">
                                <span></span>
                            </li>
                            <li><input type="button" class="login-button"  id="login" value="登录" onclick="userLogin()"></li>
                        </ul>
                        <div class="login-remember">
                            <label><input type="checkbox" id="remPwd">&nbsp;记住密码
                            <input type="checkbox" id="noLogin">&nbsp;一月免登录</label>
                            <a href="register.html">去注册</a>
                        </div>
                        <ol>
                            <span class="logleft"></span>
                            <p class="logmid">其他登录方式</p>
                            <span class="logright"></span>
                        </ol>
                        <div class="other">
                            <span>
                                <a href="https://graph.qq.com/oauth2.0/show?which=Login&display=pc&response_type=code&client_id=101417732&redirect_uri=http://wx01.lecake.com/customer/qq-callback.html&state=1f3dd8222df266f9507133107545601b&scope=get_user_info" class="QQ"></a>
                                <p>QQ</p>
                            </span>
                            <span class="middle">
                                <a href="https://open.weixin.qq.com/connect/qrconnect?appid=wx379340473ba5e673&redirect_uri=https%3A%2F%2Fwww.lecake.com%2Fcustomer%2Fwx-callback.html&response_type=code&scope=snsapi_login&state=state#wechat_redirect" class="weixin"></a>
                                <p>微信</p>
                            </span>
                            <span>
                                <a href="http://www.weibo.com" class="weibo"></a>
                                <p>微博</p>
                            </span>
                    </form>
                </div>
            </div>
            </div>
        </div>
    </div>

    <footer>
        <div class="footer">
            <img class="footer-logo" src="../images/logo.png" height="23" width="200" alt="">
            <div class="footer-nav">
                <a href="https://www.lecake.com/about/notice.html">诺心公告</a>
                <span>|</span>
                <a href="https://www.lecake.com/about/profile.html">关于诺心</a>
                <span>|</span>
                <a href="https://www.lecake.com/about/help.html">客服服务</a>
                <span>|</span>
                <a href="https://lecake.oss-cn-shanghai.aliyuncs.com/topic/group/business_certificate5.jpg">生产经营资质</a>
                <span>|</span>
                <a href="https://www.lecake.com/shop/help-80.html">联系我们</a>
            </div>
            <div class="footer-icon">
                <a href="http://weibo.com/21cake" target="_blank">
                    <img src="../images/footericon-01.png">
                </a>
                <a class="footer-weixin">
                    <div class="footer-erweima footer-weixin-erweima">
                        <img src="../images/erweima.png">
                    </div>
                    <img src="../images/footericon-02.png">
                </a>
                <a class="footer-app">x
                    <div class="footer-erweima footer-app-erweima">
                        <img src="../images/footer-erweima.png">
                    </div>
                    APP
                </a>
            </div>

            <div class="footer-text">
                <span>订购专线：4001-578-578（服务时间 09:00–21:00）</span>
                <span>客服电话：021-23099721（全国） | services@lecake.com（邮箱）</span>
                <span>杭州/广州：提前5小时预订；北京：提前6小时预订；上海：提前5.5-6小时预订；天津/苏州/无锡/深圳：提前8小时预订（部分偏远地区除外，当日22点以后订单，于次日8点开始审核） </span>
                <span>当日蛋糕配送截止下单时间：北京：16:50；上海：16:30；杭州/广州：13:50；天津：10:30；苏州/无锡/深圳：11:00</span>
                <span>网站注册公司名称: 诺心食品（上海）有限公司  地址: 上海市徐汇区虹漕路68号锦和中心7楼A、C单元 </span>
            </div>
            <div class="footer-copyright">
                <span>Copyright© 诺心leCake蛋糕官网商城 2010-2022, 版权所有 <a style="color: #9a9a9a" target="_blank" href="https://beian.miit.gov.cn/#/Integrated/index">沪ICP备10211730号-2</a></span>
            </div>
        </div>
    </footer>
         
</body>
<script src="../js/login.js"></script>
</html>